﻿<template>
    <el-tabs v-model="tabls" type="border-card">
        <el-tab-pane label="项目总结" name="conclusion">
            <el-form :model="projectconclusion" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-row>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="实际开始时间" prop="ApplyUserid">
                            <el-date-picker type="date" placeholder="选择日期" v-model="projectconclusion.ActualStartDate" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="实际结束时间" prop="ApplyUserid">
                            <el-date-picker type="date" placeholder="选择日期" v-model="projectconclusion.ActualEndDate" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="实际产值" prop="ApplyUserid">
                            <el-input type="text" v-model="projectconclusion.ActualMoney" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="实际人数" prop="ApplyUserid"> 
                            <el-input type="text" id="WriteOffTax" name="WriteOffTax" v-model="projectconclusion.ActualPeopleAmount" />
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="计划成本" prop="ApplyUserid">
                            <el-input type="text" v-model="projectconclusion.PlanCost" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" :offset="1">
                        <el-form-item label="实际成本" prop="ApplyUserid">
                            <el-input type="text" id="WriteOffTax" name="WriteOffTax" v-model="projectconclusion.ActualCost" />
                        </el-form-item>
                    </el-col>
                </el-row>


                <el-row>
                    <el-col :span="21" :offset="1">
                        <el-form-item label="项目管理总结" prop="ApplyUserid">
                            <el-input type="textarea" :autosize="{ minRows: 5, maxRows: 5}" v-model="projectconclusion.ManagementSituation" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="21" :offset="1">
                        <el-form-item label="项目技术总结" prop="ApplyUserid">
                            <el-input type="textarea" :autosize="{ minRows: 5, maxRows: 5}" v-model="projectconclusion.TechnicalSituation" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="21" :offset="1">
                        <el-form-item label="项目经营总结" prop="ApplyUserid">
                            <el-input type="textarea" :autosize="{ minRows: 5, maxRows: 5}" v-model="projectconclusion.BusinessSituation" />
                        </el-form-item>
                    </el-col>
                </el-row>

                <div style="text-align:center">
                    <el-button type="success" @click="AddSubmit">项目总结</el-button>
                </div>
            </el-form>
        </el-tab-pane>
        <el-tab-pane label="文件上传" name="Upload">
            <el-table :data="tableData"
                      style="width: 100%">
                <el-table-column prop="dbtype"
                                 label="类型">
                </el-table-column>
                <el-table-column prop="operation"
                                 label="文件">
                    <template slot-scope="scope">
                       <div    v-if="scope.row.operation=='16'">
                           <UploadFileF 
                              ref='UploadFileF_AddContract16'
                              :multiple="false"
                              :another-data="AnotherData"
                              :showfilelist="true"
                              :upshow="false"
                              content="选择文件"
                              btnsize="medium"
                           ></UploadFileF>
                       </div>
                        <div    v-else-if="scope.row.operation=='32'">
                            <UploadFileF
                                    ref='UploadFileF_AddContract32'
                                    :multiple="false"
                                    :another-data="AnotherData"
                                    :showfilelist="true"
                                    :upshow="false"
                                    content="选择文件"
                                    btnsize="medium"
                            ></UploadFileF>
                        </div>
                        <div    v-else-if="scope.row.operation=='64'">
                            <UploadFileF
                                    ref='UploadFileF_AddContract64'
                                    :multiple="false"
                                    :another-data="AnotherData"
                                    :showfilelist="true"
                                    :upshow="false"
                                    content="选择文件"
                                    btnsize="medium"
                            ></UploadFileF>
                        </div>
                        <div    v-else>
                            <UploadFileF
                                    ref='UploadFileF_AddContract128'
                                    :multiple="false"
                                    :another-data="AnotherData"
                                    :showfilelist="true"
                                    :upshow="false"
                                    content="选择文件"
                                    btnsize="medium"
                            ></UploadFileF>
                        </div>

                    </template>
                </el-table-column>


                <el-table-column prop="operation"
                                 label="操作">
                    <template slot-scope="scope">
                        <el-button size="mini"
                                   type="primary"
                                   @click="handleUpload(scope.$index, scope.row)">上传</el-button>

                        <el-button size="mini"
                                   type="success"
                                   @click="handleDown(scope.$index, scope.row)">下载</el-button>
                    </template>
                </el-table-column>


            </el-table>






        </el-tab-pane>
    </el-tabs>
</template>

<script>
    import UploadFileF from "../UploadFileF";
    import * as publicjs from "../../../public/Scriput/Public";
    export default {
        name: "ProjectSummary",
        props: {
            project: {
                type: Object,
                required: true,
            },
        },
        components: {
            UploadFileF,
        },
        data() {
            return {
                tableData: [{
                    dbtype: '技术交底资料',
                    operation: '16',
                }, {
                    dbtype: '竣工验收报告',
                    operation: '32',

                }, {
                    dbtype: '质检报告',
                    operation: '64',

                }, {
                    dbtype: '审计报告',
                    operation: '128',

                }],
                tabls: "conclusion",
                projectconclusion: {},
                //文件上传参数
                //文件上传初始化；type为16代表技术交底资料，32代表竣工验收报告，64代表质检报告，128代表开工审计报告
                AnotherData: {
                    FileType: 2,
                    id: this.project.Id,
                    Type: 16,
                    Single: true,
                },
            }
        },
        watch: {
            project: function (val) {
                console.log(val)
            }
        },
        mounted() {
            let _this = this;
            _this.tabls = "conclusion";
            _this.$nextTick(() => {
                console.log(_this.project)
                publicjs.http(this.$http, this.$message);
            })
        },
        methods: {
            handleUpload(index, obj) {
                this.AnotherData.Type = obj.operation;
                this.AnotherData.id = this.project.Id;
                console.log(this.AnotherData)
                var nameval = "UploadFileF_AddContract" + obj.operation;
                if (this.$refs[nameval].fileList.length == 0) {
                    this.$message.info("请优先添加文件在进行上传操作")
                } else if (this.$refs[nameval].fileList.length == 1) {
                     this.$refs[nameval].submitUpload()
                } else {
                    this.$message.info("该操作只允许上传一份文件内容");
                }
            },

            handleDown(index, obj) {
                // console.log(obj.operation)
                //console.log(this.project)
                publicjs.DownLoadFile({ id: this.project.Id, FileType: 2, Type: obj.operation, FileName: "" });
            },


            GetAllData() {
                let loadding = this.openLoading("数据加载中...");
                this.$http.post("/Project1/GetAllSummaryData", { id: this.project.Id }).then(res => {
                    loadding.close();
                    var data = res.data.mess;
                    if (data.IsSuccess) {
                        this.projectconclusion = data.projectSummary
                        //InitData(data.projectSummary);
                    } else {
                        this.$message.error(data.Msg)
                    }
                }).catch(() => {
                    loadding.close();
                    this.$message.error('服务器异常,请联系管理员!')
                })
            },
            AddSubmit() {
                let loadding = this.openLoading("数据加载中...");
                this.projectconclusion.ProjectId = this.project.Id;
                this.$http.post("/Project1/UpdateProjectSummary", { data: this.projectconclusion }).then(res => {
                    console.log(res.data)
                    loadding.close();
                    var data = res.data.mes;
                    if (data.IsSuccess) {
                        this.$message.success(data.Msg)
                    } else {
                        this.$message.error(data.Msg)
                    }
                }).catch(() => {
                    loadding.close();
                    this.$message.error('服务器异常,请联系管理员!')
                })
            },
        }
    }
</script>

<style scoped>
</style>
